#include <bits/stdc++.h>
using namespace std;
int n, a[200005], b[200005], maxn;
void dfs(int dep)
{
    if (dep == n + 1)
    {
        int sum = 0;
        for (int i = 1; i <= n; i++)
        {
            for (int j = i - 1; j >= 1; j--)
            {
                if (b[i] == b[j] && a[i] == a[j])
                {
                    sum += a[i];
                    break;
                }
                else if (b[i] == b[j])
                    break;
            }
        }
        maxn = max(maxn, sum);
        return;
    }
    b[dep] = 1;
    dfs(dep + 1);
    b[dep] = 0;
    dfs(dep + 1);
}
int main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out", "r", stdout);
    int t;
    cin >> t;
    while (t--)
    {
        cin >> n;
        maxn = 0;
        memset(b, 0, sizeof(b));
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        dfs(1);
        cout << maxn << endl;
    }
    return 0;
}